Skip to content

feat(memory): add version-aware development history core - #456

Draft
Anduin9527 wants to merge 22 commits into
libra-tools:mainfrom
Anduin9527:codex/memory-m2-core-draft-pr
Draft

feat(memory): add version-aware development history core#456
Anduin9527 wants to merge 22 commits into
libra-tools:mainfrom
Anduin9527:codex/memory-m2-core-draft-pr

Conversation

@Anduin9527

@Anduin9527 Anduin9527 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add repository-local, event-sourced Memory storage with immutable revisions, append-only events, CAS-protected refs, and rebuildable SQLite projections.
  • Compile terminal Task and Intent development history into version-bound Episodes with structured evidence.
  • Add deterministic FTS5/BM25 retrieval, Git applicability checks, and audited context injection through context-selection receipts.
  • Expose Memory search/show/status/rebuild commands and Agent Bridge 1.2 integration: audited memory.recall plus opt-in memory.episode.record for completed DSH turns.

Architecture

The implementation follows the design accepted in #454:

  1. Content-addressed objects and the protected Memory ref preserve authoritative history.
  2. SQLite stores rebuildable projections, bounded compiler jobs, FTS5 indexes, and context-selection receipts.
  3. Task Episodes summarize one development task; Intent Episodes pin contributing Task revisions.
  4. Retrieval freezes repository, code, and projection state before ranking and context injection.
  5. DSH capture records canonical Task/Run/Decision/TaskEvent evidence and invokes the existing Episode compiler, admission policy, and writer. The caller cannot choose repository authority or actor identity.

Upstream integration

Merged upstream main through 2ebd409045b5114707986b66a7a6b42b5a4a4b7e, preserving the existing PR branch history.

  • Preserve Operation v2 schema/GC behavior and the newer fully-qualified push/delete resolution.
  • Keep Memory authority excluded from ordinary, --all, and --mirror push.
  • Honor upstream's removal of generated web/out assets.
  • Move the unpublished Memory migrations after Operation v2:
    • 2026090701_memory_core
    • 2026090702_memory_fts_search
    • 2026090703_context_selection_receipt

The migration runner only applies versions above the current tip. The new ordering prevents repositories already on Operation v2 from skipping Memory tables. Memory SQL semantics are unchanged; historical down/up fixtures exclude the forward-only Operation v2 migration, and the Memory upgrade test starts from the actual upstream schema.

DSH integration

Enable completed-turn capture with LIBRA_DSH_MEMORY_MODEL=deepseek-chat on the bridge and captureMemoryEpisodes: true in the separately maintained DSH plugin. A compiler credential is required. Recall alone remains available without a compiler model.

Capture uses the first-turn code HEAD and completion HEAD, targets that turn's compilation job, and retains SHA-1 code-anchor compatibility. The plugin's real DSH v0.1.2-alpha.1 gate previously generated a structured Episode with a real compiler model, verified its stored projection/receipt, remounted the plugin, and recalled the result through a real headless model run.

The shelved native Libra DSH runtime is not included. The plugin's Cordis refactor is separate preparation work, not part of this PR.

Verification

Merged-candidate Docker checks:

  • cargo test --test db_migration_test --test operation_schema_v2 --test agent_bridge_migration_test --test agent_capture_migration_test -- --test-threads=1: 97 passed (80 + 3 + 5 + 9).
  • Existing development-database upgrade: Libra 0.22.16 still recalls the earlier real-model Episode with the same note and revision IDs.
  • cargo +nightly fmt --all --check: passed.
  • cargo clippy --all-targets --all-features -- -D warnings: passed.
  • cargo test --test compat_serial_registry --test publish_worker_template_embed_test -- --test-threads=1: 23 passed.
  • Focused regressions for checkpoint capture, workspace-lease fencing, command configuration isolation, and concurrent migration application: passed.

Full-suite validation remains subject to the PR's CI results; the checks above are focused local verification, not a claim that the complete suite passed.

Review guide

  1. Migrations, contracts, writer, and projection replay.
  2. Bounded evidence sources, per-root generation jobs, and Episode compilers.
  3. FTS5/BM25 reader, frozen views, and audited context injection.
  4. Bridge session binding, completed-turn capture, code anchors, and Memory CLI.

Memory remains repository-local. Remote Memory publication, the separate DSH plugin refactor, and the shelved native DSH runtime are out of scope.

Refs #451
Builds on #454

Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Signed-off-by: anduin9527 <anduin9527@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant